<template>
    <div>
        <el-form-item label="当前分组权重占比">
            <el-input-number v-model="parentContent.parentWeight" :precision="2" :min="0" :max="100"
                             @change="changeWeight"></el-input-number>
        </el-form-item>
    </div>
</template>

<script>
import {formGlobalConf, containerConfigList} from '@/components/form-designer/container-panel/containerConfig'

export default {
    name: "parentWeightEditor",
    props: {
        parentContent: {
            type: Object
        }
    },
    data() {
        return {
            memoryNum: 0,
        }
    },
    created() {
        this.memoryNum = this.$props.parentContent.parentWeight
    },
    methods: {
        changeWeight() {
            let num = 0;
            for (let val of containerConfigList) {
                if (this.parentContent.id == val.id) continue
                num = num + val.parentWeight
            }
            num = num + this.parentContent.parentWeight
            if (100 < num) {
                //如果超出了就还是设为之前的权重比对
                this.parentContent.parentWeight = this.memoryNum
                this.$message.error('权重设置超出了当前全局权重占比')
            }

        }
    }
}
</script>

<style scoped>

</style>